﻿<UserControl x:Class="IssueVision.Client.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:system="clr-namespace:System;assembly=mscorlib" 
    xmlns:local="clr-namespace:IssueVision.Client;assembly=IssueVision.Main"
    xmlns:common="clr-namespace:IssueVision.Common;assembly=IssueVision.Common"
    xmlns:menu="clr-namespace:System.Windows.Controls;assembly=MenuControls"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
    
    <UserControl.Resources>
        <common:NotOperatorValueConverter x:Key="notOperatorValueConverter"/>
        <common:BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter"/>
    </UserControl.Resources>

    <toolkit:BusyIndicator Style="{StaticResource BusyIndicatorStyle}" IsBusy="{Binding Path=IsBusy}">
        <common:MainPageControl x:Name="mainPageControl" IsLoggedIn="{Binding Path=IsLoggedIn}">
            <common:MainPageControl.TitleContent>
                <toolkit:DockPanel Style="{StaticResource MainPageTitleStyle}">
                    <TextBlock Text="ISSUEVISION" Style="{StaticResource MainPageTitleTextOneStyle}"/>
                    <TextBlock Text="for Silverlight" Style="{StaticResource MainPageTitleTextTwoStyle}"/>
                    <StackPanel Visibility="{Binding Path=IsLoggedIn, 
                                             Mode=OneWay, 
                                             Converter={StaticResource booleanToVisibilityConverter}}"
                                Style="{StaticResource LogoutPanelStyle}">
                        <TextBlock Text="{Binding Path=WelcomeText}"
                                   Style="{StaticResource WelcomeTextStyle}"/>
                        <TextBlock Text="|" Style="{StaticResource SpacerStyle}"/>
                        <TextBlock Text="{Binding Path=CurrentScreenText}"
                                   Style="{StaticResource CurrentScreenTextStyle}"/>
                        <TextBlock Text="|" Style="{StaticResource SpacerStyle}"/>
                        <HyperlinkButton x:Name="hyperlinkButton_Logout" Content="logout" 
                                         Style="{StaticResource LogoutButtonStyle}"
                                         Command="{Binding Path=LogoutCommand}"
                                         IsEnabled="{Binding Path=IsLoggedOut,
                                                     Mode=OneWay, 
                                                     Converter={StaticResource notOperatorValueConverter}}">
                            <HyperlinkButton.CommandParameter>
                                <system:Boolean>False</system:Boolean>
                            </HyperlinkButton.CommandParameter>
                        </HyperlinkButton>
                    </StackPanel>
                </toolkit:DockPanel>
            </common:MainPageControl.TitleContent>
            <common:MainPageControl.LoggedInMenuContent>
                <menu:Menu Style="{StaticResource LoggedInMenuStyle}">
                    <menu:MenuItem Header="Home"
                                   Command="{Binding Path=ChangeScreenCommand}"
                                   CommandParameter="Home"/>
                    <menu:MenuItem Header="Issues">
                        <menu:MenuItem Header="New Issue"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="New Issue"/>
                        <menu:MenuItem Header="My Issues"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="My Issues"/>
                        <menu:MenuItem Header="All Issues"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="All Issues"/>
                    </menu:MenuItem>
                    <menu:MenuItem Header="Reports">
                        <menu:MenuItem Header="Bug Report"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="Bug Report"/>
                    </menu:MenuItem>
                    <menu:MenuItem Header="Admin">
                        <menu:MenuItem Header="My Profile"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="My Profile"/>
                        <menu:MenuItem Header="User Maintenance"
                                       Visibility="{Binding Path=IsAdmin, 
                                                    Mode=OneWay, 
                                                    Converter={StaticResource booleanToVisibilityConverter}}"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="User Maintenance"/>
                        <menu:MenuItem Header="Audit Issue"
                                       Visibility="{Binding Path=IsAdmin, 
                                                    Mode=OneWay, 
                                                    Converter={StaticResource booleanToVisibilityConverter}}"
                                       Command="{Binding Path=ChangeScreenCommand}"
                                       CommandParameter="Audit Issue"/>
                    </menu:MenuItem>
                    <menu:MenuItem Header="Themes">
                        <menu:MenuItem Header="Bureau Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="BureauBlue.xaml"
                                       IsChecked="{Binding IsBureauBlueTheme}"/>
                        <menu:MenuItem Header="Expression Light"                                           
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="ExpressionLight.xaml"
                                       IsChecked="{Binding IsExpressionLightTheme}"/>
                        <menu:MenuItem Header="Shiny Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="ShinyBlue.xaml"
                                       IsChecked="{Binding IsShinyBlueTheme}"/>
                        <menu:MenuItem Header="Twilight Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="TwilightBlue.xaml"
                                       IsChecked="{Binding IsTwilightBlueTheme}"/>
                    </menu:MenuItem>
                </menu:Menu>
            </common:MainPageControl.LoggedInMenuContent>
            <common:MainPageControl.LoggedOutMenuContent>
                <menu:Menu Style="{StaticResource LoggedOutMenuStyle}">
                    <menu:MenuItem Header="Themes">
                        <menu:MenuItem Header="Bureau Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="BureauBlue.xaml"
                                       IsChecked="{Binding IsBureauBlueTheme}"/>
                        <menu:MenuItem Header="Expression Light"                                           
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="ExpressionLight.xaml"
                                       IsChecked="{Binding IsExpressionLightTheme}"/>
                        <menu:MenuItem Header="Shiny Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="ShinyBlue.xaml"
                                       IsChecked="{Binding IsShinyBlueTheme}"/>
                        <menu:MenuItem Header="Twilight Blue"
                                       Command="{Binding Path=ChangeThemeCommand}"
                                       CommandParameter="TwilightBlue.xaml"
                                       IsChecked="{Binding IsTwilightBlueTheme}"/>
                    </menu:MenuItem>
                </menu:Menu>
            </common:MainPageControl.LoggedOutMenuContent>
            <common:MainPageControl.LoginPageContent>
                <Grid Style="{StaticResource MainLoginPageStyle}">
                    <local:LoginForm HorizontalAlignment="Center" VerticalAlignment="Center" />
                </Grid>
            </common:MainPageControl.LoginPageContent>
            <common:MainPageControl.MainPageContent>
                <common:MainPageContentControl x:Name="mainPageContent" Style="{StaticResource MainPageContentStyle}">
                    <local:Home/>
                </common:MainPageContentControl>
            </common:MainPageControl.MainPageContent>
        </common:MainPageControl>
    </toolkit:BusyIndicator>

</UserControl>
